home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / C / DO.H < prev    next >
Text File  |  1997-04-27  |  1KB  |  60 lines

  1. // recursive func!
  2. void dofile(void) {
  3.   word incoff;
  4.   word p;
  5.   //open file
  6.   //send to other routine
  7.   //close file
  8.   ch++;
  9.   //below is almost impossible  (mh=64)
  10.   if (ch==mh) error("LIMIT:Too many include files(64) (increase mh in sources)\r\n");
  11.   h=open(file,O_BINARY|O_RDONLY);
  12.   strcpy(buffn[ch],file);
  13.   if (h==-1) {
  14.     if (inc!=NULL) {
  15.       incoff=0;
  16.       while (h==-1) {
  17.         if (!(*(inc+incoff))) break;
  18.         p=0;
  19.         while (*(inc+incoff)) {
  20.           t2[p++]=*(inc+incoff++);
  21.           if ((*(inc+incoff))==';') {incoff++;break;}
  22.         }
  23.         t2[p]=0;
  24.         strcat(t2,"\\");
  25.         strcat(t2,file);
  26.         h=open(t2,O_BINARY|O_RDONLY);
  27.       }
  28.     }   
  29.         
  30.     if (h==-1) {
  31.       sprintf(str,"Can't open file : %s\r\n",file);
  32.       error(str);
  33.     }     
  34.   }       
  35.   #ifdef DEBUG
  36.     printf(" %s opened\n",file);
  37.   #endif
  38.   hs[ch]=h;
  39.   bufin[ch]=(byte *)malloc(bufsiz);
  40.   if ( ((dword) bufin[ch]) == ERROR ) error("Out of memory\n");
  41.   bufip[ch]=0;  
  42.   bufis[ch]=0;  //size left
  43.   bufln[ch]=0;  //line #
  44.   EOFF[ch]=0;
  45.   prefile();  //pre process the file!
  46.   free(bufin[ch]);
  47.   close(h);   
  48.   #ifdef DEBUG
  49.     printf("  closed\n");
  50.   #endif
  51.   ch--;
  52.   if (ch!=255) {
  53.     h=hs[ch];
  54.     if (!h) {
  55.       printf("Unknown error:h=0 ch=%d! \r\n",ch);
  56.       exit(0);
  57.     }
  58.   }
  59. }
  60.